<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/6 0006
 * Time: 17:11
 */
namespace app\modules\content\models;

use app\modules\cn\models\ResourcesPhone;
use yii\db\ActiveRecord;

class HotActive extends ActiveRecord
{
    public static function tableName()
    {
        return '{{%hot_active}}';
    }

    public function rules()
    {
        return [
            // username and password are both required
            // [['student', 'cate', '', 'duration'], 'required'],

        ];
    }

    /**
     * [getReservation 计算热门活动报名人数]
     * @Author don
     * @Date   2021-12-15
     * @param  [type]     $data [description]
     * @return [type]           [description]
     */
    public static function getReservation($data)
    {
        foreach ($data as $k => $v) {
            $count = ResourcesPhone::find()->asArray()->where('remark="' . $v['name'].'"')->count();
            $data[$k]['count'] = $v['reservations']+$count;
        }
        return $data;
    }

}